package com.策略模式2;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: wh(1835734390 @ qq.com)
 * @date: 2022/10/27 13:37
 * @description:
 * @version:
 */
@Component
public class MainDemo implements CommandLineRunner {

    @Override
    public void run(String... args) throws Exception {
        List<EntityDemo> paramList=new ArrayList<>();
        EntityDemo firstDemo = new EntityDemo("001", "firstType");
        paramList.add(firstDemo);
        EntityDemo secondDemo = new EntityDemo("002", "secondType");
        paramList.add(secondDemo);
        for (EntityDemo entityDemo : paramList) {
            EnumDemo curEnum = EnumDemo.getByCode(entityDemo.getCode());
            InterfaceDemo demoImpl = FactoryDemo.getDemoImpl(curEnum);
            demoImpl.print(entityDemo.getName());
        }
    }
}

